﻿Public Class Buscar_Moto

    Private Sub RepartidorBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.Validate()
        Me.RepartidorBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.DsMotos)

    End Sub

    Private Sub Buscar_Moto_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: esta línea de código carga datos en la tabla 'DsMotos.Repartidor' Puede moverla o quitarla según sea necesario.
        Me.RepartidorTableAdapter.Fill(Me.DsMotos.Repartidor)

    End Sub

    Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        If e.KeyChar = Convert.ToChar(13) Then
            Me.RepartidorDataGridView.Focus()
        End If
        If Me.TextBox1.Text = "" Then
            Dim busca As DataView
            busca = Me.DsMotos.Tables(0).DefaultView
            Me.RepartidorDataGridView.DataSource = busca
            Try
                busca.RowFilter = "apellido LIKE '*%'"
            Catch ex As Exception
                MessageBox.Show("Ese Articulo No Existe")
            End Try

        Else
            If Me.ComboBox1.Text = "Apellido" Then
                Dim busca As DataView
                busca = Me.DsMotos.Tables(0).DefaultView
                Me.RepartidorDataGridView.DataSource = busca
                Try
                    busca.RowFilter = "apellido LIKE '" & Me.TextBox1.Text & "%'"
                Catch ex As Exception
                    MessageBox.Show("Ese Articulo No Existe")
                End Try
            Else
                If Me.ComboBox1.Text = "Nombre" Then
                    Dim busca As DataView
                    busca = Me.DsMotos.Tables(0).DefaultView
                    Me.RepartidorDataGridView.DataSource = busca
                    Try
                        busca.RowFilter = "nombre LIKE '" & Me.TextBox1.Text & "%'"
                    Catch ex As Exception
                        MessageBox.Show("Ese Articulo No Existe")
                    End Try
                Else
                    If Me.ComboBox1.Text = "DNI" Then
                        Dim busca As DataView
                        busca = Me.DsMotos.Tables(0).DefaultView
                        Me.RepartidorDataGridView.DataSource = busca
                        Try
                            busca.RowFilter = "documento LIKE '" & Me.TextBox1.Text & "%'"
                        Catch ex As Exception
                            MessageBox.Show("Ese Articulo No Existe")
                        End Try
                    Else
                        If Me.ComboBox1.Text = "Celular" Then
                            Dim busca As DataView
                            busca = Me.DsMotos.Tables(0).DefaultView
                            Me.RepartidorDataGridView.DataSource = busca
                            Try
                                busca.RowFilter = "telefonoMovil LIKE '" & Me.TextBox1.Text & "%'"
                            Catch ex As Exception
                                MessageBox.Show("Ese Articulo No Existe")
                            End Try
                        Else
                            If Me.ComboBox1.Text = "Fecha de Nac." Then
                                Dim busca As DataView
                                busca = Me.DsMotos.Tables(0).DefaultView
                                Me.RepartidorDataGridView.DataSource = busca
                                Try
                                    busca.RowFilter = "fechaNacimiento LIKE '" & Me.TextBox1.Text & "%'"
                                Catch ex As Exception
                                    MessageBox.Show("Ese Articulo No Existe")
                                End Try
                            Else
                                If Me.ComboBox1.Text = "Vehículo" Then
                                    Dim busca As DataView
                                    busca = Me.DsMotos.Tables(0).DefaultView
                                    Me.RepartidorDataGridView.DataSource = busca
                                    Try
                                        busca.RowFilter = "vehiculo LIKE '" & Me.TextBox1.Text & "%'"
                                    Catch ex As Exception
                                        MessageBox.Show("Ese Articulo No Existe")
                                    End Try
                                Else
                                    If Me.ComboBox1.Text = "Patente" Then
                                        Dim busca As DataView
                                        busca = Me.DsMotos.Tables(0).DefaultView
                                        Me.RepartidorDataGridView.DataSource = busca
                                        Try
                                            busca.RowFilter = "dominio LIKE '" & Me.TextBox1.Text & "%'"
                                        Catch ex As Exception
                                            MessageBox.Show("Ese Articulo No Existe")
                                        End Try
                                        'end patente
                                    End If
                                    'end vehiculo
                                End If
                                'end fecha nac
                            End If
                            'end celular
                        End If
                        'end dni
                    End If
                    'end nombre
                End If
                'end apellido
            End If
        End If


    End Sub

    'Private Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
    '    If Me.TextBox1.Text = "" Then
    '        Dim busca As DataView
    '        busca = Me.DsMotos.Tables(0).DefaultView
    '        Me.RepartidorDataGridView.DataSource = busca
    '        Try
    '            busca.RowFilter = "apellido LIKE '*%'"
    '        Catch ex As Exception
    '            MessageBox.Show("Ese Articulo No Existe")
    '        End Try

    '    Else
    '        If Me.ComboBox1.Text = "Apellido" Then
    '            Dim busca As DataView
    '            busca = Me.DsMotos.Tables(0).DefaultView
    '            Me.RepartidorDataGridView.DataSource = busca
    '            Try
    '                busca.RowFilter = "apellido LIKE '" & Me.TextBox1.Text & "%'"
    '            Catch ex As Exception
    '                MessageBox.Show("Ese Articulo No Existe")
    '            End Try
    '        Else
    '            If Me.ComboBox1.Text = "Nombre" Then
    '                Dim busca As DataView
    '                busca = Me.DsMotos.Tables(0).DefaultView
    '                Me.RepartidorDataGridView.DataSource = busca
    '                Try
    '                    busca.RowFilter = "nombre LIKE '" & Me.TextBox1.Text & "%'"
    '                Catch ex As Exception
    '                    MessageBox.Show("Ese Articulo No Existe")
    '                End Try
    '            Else
    '                If Me.ComboBox1.Text = "DNI" Then
    '                    Dim busca As DataView
    '                    busca = Me.DsMotos.Tables(0).DefaultView
    '                    Me.RepartidorDataGridView.DataSource = busca
    '                    Try
    '                        busca.RowFilter = "documento LIKE '" & Me.TextBox1.Text & "%'"
    '                    Catch ex As Exception
    '                        MessageBox.Show("Ese Articulo No Existe")
    '                    End Try
    '                Else
    '                    If Me.ComboBox1.Text = "Celular" Then
    '                        Dim busca As DataView
    '                        busca = Me.DsMotos.Tables(0).DefaultView
    '                        Me.RepartidorDataGridView.DataSource = busca
    '                        Try
    '                            busca.RowFilter = "telefonoMovil LIKE '" & Me.TextBox1.Text & "%'"
    '                        Catch ex As Exception
    '                            MessageBox.Show("Ese Articulo No Existe")
    '                        End Try
    '                    Else
    '                        If Me.ComboBox1.Text = "Fecha de Nac." Then
    '                            Dim busca As DataView
    '                            busca = Me.DsMotos.Tables(0).DefaultView
    '                            Me.RepartidorDataGridView.DataSource = busca
    '                            Try
    '                                busca.RowFilter = "fechaNacimiento LIKE '" & Me.TextBox1.Text & "%'"
    '                            Catch ex As Exception
    '                                MessageBox.Show("Ese Articulo No Existe")
    '                            End Try
    '                        Else
    '                            If Me.ComboBox1.Text = "Vehículo" Then
    '                                Dim busca As DataView
    '                                busca = Me.DsMotos.Tables(0).DefaultView
    '                                Me.RepartidorDataGridView.DataSource = busca
    '                                Try
    '                                    busca.RowFilter = "vehiculo LIKE '" & Me.TextBox1.Text & "%'"
    '                                Catch ex As Exception
    '                                    MessageBox.Show("Ese Articulo No Existe")
    '                                End Try
    '                            Else
    '                                If Me.ComboBox1.Text = "Patente" Then
    '                                    Dim busca As DataView
    '                                    busca = Me.DsMotos.Tables(0).DefaultView
    '                                    Me.RepartidorDataGridView.DataSource = busca
    '                                    Try
    '                                        busca.RowFilter = "dominio LIKE '" & Me.TextBox1.Text & "%'"
    '                                    Catch ex As Exception
    '                                        MessageBox.Show("Ese Articulo No Existe")
    '                                    End Try
    '                                    'end patente
    '                                End If
    '                                'end vehiculo
    '                            End If
    '                            'end fecha nac
    '                        End If
    '                        'end celular
    '                    End If
    '                    'end dni
    '                End If
    '                'end nombre
    '            End If
    '            'end apellido
    '        End If
    '    End If
    'End Sub

    Private Sub RepartidorDataGridView_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles RepartidorDataGridView.DoubleClick
        Me.Dispose()
        Me.Close()
    End Sub


    
    Private Sub RepartidorDataGridView_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles RepartidorDataGridView.KeyPress
        If e.KeyChar = Convert.ToChar(13) Then
            Me.Dispose()
            Me.Close()
        End If
    End Sub

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

    End Sub
End Class